<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>popot-2.01: /opt/GoogleCode/popot/trunk/popot-2.01/src/rng_generators.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">popot-2.01
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="examples.html"><span>Examples</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">/opt/GoogleCode/popot/trunk/popot-2.01/src/rng_generators.h</div>  </div>
</div>
<div class="contents">
<a href="rng__generators_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef POPOT_RNG_GENERATORS_H</span>
<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define POPOT_RNG_GENERATORS_H</span>
<a name="l00003"></a>00003 <span class="preprocessor"></span>
<a name="l00004"></a>00004 <span class="preprocessor">#include &lt;cstdlib&gt;</span>
<a name="l00005"></a>00005 <span class="preprocessor">#include &lt;ctime&gt;</span>
<a name="l00006"></a>00006 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00007"></a>00007 
<a name="l00008"></a>00008 
<a name="l00009"></a>00009 <span class="preprocessor">#include &quot;<a class="code" href="mersenne_8h.html">mersenne.h</a>&quot;</span>
<a name="l00010"></a>00010 
<a name="l00011"></a>00011 <span class="comment">// For random number generations</span>
<a name="l00012"></a>00012 <span class="comment">// There are some discussions in papers of M. Clerc</span>
<a name="l00013"></a>00013 <span class="comment">// e.g. &quot;Randomness matters&quot;</span>
<a name="l00014"></a>00014 
<a name="l00015"></a>00015 <span class="keyword">namespace </span>popot
<a name="l00016"></a>00016 {
<a name="l00017"></a>00017   <span class="keyword">namespace </span>rng
<a name="l00018"></a>00018   {
<a name="l00019"></a>00019 
<a name="l00020"></a>00020     <span class="comment">/*</span>
<a name="l00021"></a>00021 <span class="comment">      JKISS</span>
<a name="l00022"></a>00022 <span class="comment">      See http://www.cs.ucl.ac.uk/staff/D.Jones/GoodPracticeRNG.pdf</span>
<a name="l00023"></a>00023 <span class="comment">    */</span>
<a name="l00024"></a>00024    <span class="keyword">class </span>JKissRNG
<a name="l00025"></a>00025     {
<a name="l00026"></a>00026       <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> x;
<a name="l00027"></a>00027       <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> y;
<a name="l00028"></a>00028       <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> z;
<a name="l00029"></a>00029       <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> c;
<a name="l00030"></a>00030    
<a name="l00031"></a>00031     <span class="keyword">public</span>:
<a name="l00032"></a><a class="code" href="classpopot_1_1rng_1_1JKissRNG.html#a0ce4135b4b2cc09f5daf966d2035404e">00032</a>       <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="classpopot_1_1rng_1_1JKissRNG.html#a0ce4135b4b2cc09f5daf966d2035404e">nb_calls</a>;
<a name="l00033"></a>00033 <span class="preprocessor">#if defined(__GXX_EXPERIMENTAL_CXX0X__)</span>
<a name="l00034"></a>00034 <span class="preprocessor"></span>      <span class="keyword">static</span> constexpr <span class="keywordtype">double</span> <a class="code" href="classpopot_1_1rng_1_1JKissRNG.html#a4792ae8bbb32cb1cafb4536adda12514">RNG_RAND_MAX</a> = 4294967296.0;
<a name="l00035"></a>00035 <span class="preprocessor">#else</span>
<a name="l00036"></a><a class="code" href="classpopot_1_1rng_1_1JKissRNG.html#a4792ae8bbb32cb1cafb4536adda12514">00036</a> <span class="preprocessor"></span>      <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">double</span> <a class="code" href="classpopot_1_1rng_1_1JKissRNG.html#a4792ae8bbb32cb1cafb4536adda12514">RNG_RAND_MAX</a> = 4294967296.0;
<a name="l00037"></a>00037 <span class="preprocessor">#endif</span>
<a name="l00038"></a>00038 <span class="preprocessor"></span>
<a name="l00039"></a><a class="code" href="classpopot_1_1rng_1_1JKissRNG.html#a469655f32c28517b0fdb4e9a21efcb8e">00039</a>       <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classpopot_1_1rng_1_1JKissRNG.html#a469655f32c28517b0fdb4e9a21efcb8e">rng_srand</a>()
<a name="l00040"></a>00040       {
<a name="l00041"></a>00041         <a class="code" href="classpopot_1_1rng_1_1JKissRNG.html#a469655f32c28517b0fdb4e9a21efcb8e">rng_srand</a>(time(NULL));
<a name="l00042"></a>00042       }
<a name="l00043"></a><a class="code" href="classpopot_1_1rng_1_1JKissRNG.html#ac18318f68ffcc65d6ebf6f8309a282b3">00043</a>       <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classpopot_1_1rng_1_1JKissRNG.html#a469655f32c28517b0fdb4e9a21efcb8e">rng_srand</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> seed)
<a name="l00044"></a>00044       {
<a name="l00045"></a>00045         x = seed | 1;
<a name="l00046"></a>00046         y = seed | 2;
<a name="l00047"></a>00047         z = seed | 4;
<a name="l00048"></a>00048         c = 0;
<a name="l00049"></a>00049         <a class="code" href="classpopot_1_1rng_1_1JKissRNG.html#a0ce4135b4b2cc09f5daf966d2035404e">nb_calls</a> = 0;
<a name="l00050"></a>00050       }
<a name="l00051"></a><a class="code" href="classpopot_1_1rng_1_1JKissRNG.html#ae7c4e956a4547f5191b668cc33ebb733">00051</a>       <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classpopot_1_1rng_1_1JKissRNG.html#ae7c4e956a4547f5191b668cc33ebb733">rng_warm_up</a>(<span class="keywordtype">void</span>)
<a name="l00052"></a>00052       {
<a name="l00053"></a>00053         <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i = 0 ; i &lt; 10000 ; ++i)
<a name="l00054"></a>00054           <a class="code" href="classpopot_1_1rng_1_1JKissRNG.html#a4487f80a003004e16525f09fa85f2ec3">rng_rand</a>();
<a name="l00055"></a>00055       }
<a name="l00056"></a><a class="code" href="classpopot_1_1rng_1_1JKissRNG.html#a4487f80a003004e16525f09fa85f2ec3">00056</a>       <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classpopot_1_1rng_1_1JKissRNG.html#a4487f80a003004e16525f09fa85f2ec3">rng_rand</a>(<span class="keywordtype">void</span>)
<a name="l00057"></a>00057       {
<a name="l00058"></a>00058         <a class="code" href="classpopot_1_1rng_1_1JKissRNG.html#a0ce4135b4b2cc09f5daf966d2035404e">nb_calls</a> ++;
<a name="l00059"></a>00059         <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> t;
<a name="l00060"></a>00060         x = 314527869 * x + 1234567;
<a name="l00061"></a>00061         y ^= y &lt;&lt; 5; y ^= y &gt;&gt; 7; y ^= y &lt;&lt; 22;
<a name="l00062"></a>00062         t = 4294584393ULL * z + c; c = t &gt;&gt; 32; z = t;
<a name="l00063"></a>00063         <span class="keywordflow">return</span> x + y + z;
<a name="l00064"></a>00064       }
<a name="l00065"></a>00065     };
<a name="l00066"></a>00066 
<a name="l00067"></a>00067     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> JKissRNG::x;
<a name="l00068"></a>00068     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> JKissRNG::y;
<a name="l00069"></a>00069     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> JKissRNG::z;
<a name="l00070"></a>00070     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> JKissRNG::c;
<a name="l00071"></a>00071     <span class="keywordtype">int</span> JKissRNG::nb_calls;
<a name="l00072"></a>00072 
<a name="l00073"></a>00073     <span class="comment">/*</span>
<a name="l00074"></a>00074 <span class="comment"></span>
<a name="l00075"></a>00075 <span class="comment">      KISS</span>
<a name="l00076"></a>00076 <span class="comment">      http://www.helsbreth.org/random/rng_kiss.html</span>
<a name="l00077"></a>00077 <span class="comment"></span>
<a name="l00078"></a>00078 <span class="comment">      the idea is to use simple, fast, individually promising</span>
<a name="l00079"></a>00079 <span class="comment">      generators to get a composite that will be fast, easy to code</span>
<a name="l00080"></a>00080 <span class="comment">      have a very long period and pass all the tests put to it.</span>
<a name="l00081"></a>00081 <span class="comment">      The three components of KISS are</span>
<a name="l00082"></a>00082 <span class="comment">      x(n)=a*x(n-1)+1 mod 2^32</span>
<a name="l00083"></a>00083 <span class="comment">      y(n)=y(n-1)(I+L^13)(I+R^17)(I+L^5),</span>
<a name="l00084"></a>00084 <span class="comment">      z(n)=2*z(n-1)+z(n-2) +carry mod 2^32</span>
<a name="l00085"></a>00085 <span class="comment">      The y&#39;s are a shift register sequence on 32bit binary vectors</span>
<a name="l00086"></a>00086 <span class="comment">      period 2^32-1;</span>
<a name="l00087"></a>00087 <span class="comment">      The z&#39;s are a simple multiply-with-carry sequence with period</span>
<a name="l00088"></a>00088 <span class="comment">      2^63+2^32-1.  The period of KISS is thus</span>
<a name="l00089"></a>00089 <span class="comment">      2^32*(2^32-1)*(2^63+2^32-1) &gt; 2^127</span>
<a name="l00090"></a>00090 <span class="comment">    */</span>
<a name="l00091"></a>00091 
<a name="l00092"></a>00092     <span class="keyword">class </span>KissRNG32
<a name="l00093"></a>00093     {
<a name="l00094"></a>00094       <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> kiss_x;
<a name="l00095"></a>00095       <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> kiss_y;
<a name="l00096"></a>00096       <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> kiss_z;
<a name="l00097"></a>00097       <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> kiss_w;
<a name="l00098"></a>00098       <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> kiss_carry;
<a name="l00099"></a>00099       <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> kiss_k;
<a name="l00100"></a>00100       <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> kiss_m;
<a name="l00101"></a>00101       
<a name="l00102"></a>00102     <span class="keyword">public</span>:
<a name="l00103"></a>00103 
<a name="l00104"></a><a class="code" href="classpopot_1_1rng_1_1KissRNG32.html#a3232b5bebefa0f1be4a9ac13dcf241fe">00104</a>       <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="classpopot_1_1rng_1_1KissRNG32.html#a3232b5bebefa0f1be4a9ac13dcf241fe">nb_calls</a>;
<a name="l00105"></a>00105 <span class="preprocessor">#if defined(__GXX_EXPERIMENTAL_CXX0X__)</span>
<a name="l00106"></a>00106 <span class="preprocessor"></span>      <span class="keyword">static</span> constexpr <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> <a class="code" href="classpopot_1_1rng_1_1KissRNG32.html#a5188b77453c89da2db68208fa5d77099">RNG_RAND_MAX</a> = 4294967295ULL;
<a name="l00107"></a>00107 <span class="preprocessor">#else</span>
<a name="l00108"></a><a class="code" href="classpopot_1_1rng_1_1KissRNG32.html#a5188b77453c89da2db68208fa5d77099">00108</a> <span class="preprocessor"></span>      <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> <a class="code" href="classpopot_1_1rng_1_1KissRNG32.html#a5188b77453c89da2db68208fa5d77099">RNG_RAND_MAX</a> = 4294967295ULL;
<a name="l00109"></a>00109 <span class="preprocessor">#endif</span>
<a name="l00110"></a>00110 <span class="preprocessor"></span>
<a name="l00111"></a><a class="code" href="classpopot_1_1rng_1_1KissRNG32.html#a0945938f0e3b054b701ef0b8bfb76570">00111</a>       <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classpopot_1_1rng_1_1KissRNG32.html#a0945938f0e3b054b701ef0b8bfb76570">rng_srand</a>()
<a name="l00112"></a>00112       {
<a name="l00113"></a>00113         <span class="comment">// Random initialization of the seed</span>
<a name="l00114"></a>00114         <span class="comment">// To really get different seeds, ensure that the calls</span>
<a name="l00115"></a>00115         <span class="comment">// are separated by at least 1 s.</span>
<a name="l00116"></a>00116         <a class="code" href="classpopot_1_1rng_1_1KissRNG32.html#a0945938f0e3b054b701ef0b8bfb76570">rng_srand</a>(time(NULL));
<a name="l00117"></a>00117         <a class="code" href="classpopot_1_1rng_1_1KissRNG32.html#a3232b5bebefa0f1be4a9ac13dcf241fe">nb_calls</a> = 0;
<a name="l00118"></a>00118       }
<a name="l00119"></a>00119 
<a name="l00120"></a><a class="code" href="classpopot_1_1rng_1_1KissRNG32.html#a45b01f24f380d6363ccce0cdeb3eb038">00120</a>       <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classpopot_1_1rng_1_1KissRNG32.html#a0945938f0e3b054b701ef0b8bfb76570">rng_srand</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> seed)
<a name="l00121"></a>00121       {
<a name="l00122"></a>00122         kiss_x = seed | 1;
<a name="l00123"></a>00123         kiss_y = seed | 2;
<a name="l00124"></a>00124         kiss_z = seed | 4;
<a name="l00125"></a>00125         kiss_w = seed | 8;
<a name="l00126"></a>00126         kiss_carry = 0;
<a name="l00127"></a>00127         <a class="code" href="classpopot_1_1rng_1_1KissRNG32.html#a3232b5bebefa0f1be4a9ac13dcf241fe">nb_calls</a> = 0;
<a name="l00128"></a>00128       }
<a name="l00129"></a>00129 
<a name="l00130"></a><a class="code" href="classpopot_1_1rng_1_1KissRNG32.html#ac21bec4272147cf23f3cbea9db9d7a0c">00130</a>       <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classpopot_1_1rng_1_1KissRNG32.html#ac21bec4272147cf23f3cbea9db9d7a0c">rng_warm_up</a>(<span class="keywordtype">void</span>)
<a name="l00131"></a>00131       {
<a name="l00132"></a>00132         <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i = 0 ; i &lt; 10000 ; ++i)
<a name="l00133"></a>00133           <a class="code" href="classpopot_1_1rng_1_1KissRNG32.html#a6808c02f1b7f50a36a9bb3c5143b9ff1">rng_rand</a>();
<a name="l00134"></a>00134       }
<a name="l00135"></a>00135 
<a name="l00136"></a><a class="code" href="classpopot_1_1rng_1_1KissRNG32.html#a6808c02f1b7f50a36a9bb3c5143b9ff1">00136</a>       <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> <a class="code" href="classpopot_1_1rng_1_1KissRNG32.html#a6808c02f1b7f50a36a9bb3c5143b9ff1">rng_rand</a>(<span class="keywordtype">void</span>)
<a name="l00137"></a>00137       {
<a name="l00138"></a>00138         kiss_x = kiss_x * 69069 + 1;
<a name="l00139"></a>00139         kiss_y ^= kiss_y &lt;&lt; 13;
<a name="l00140"></a>00140         kiss_y ^= kiss_y &gt;&gt; 17;
<a name="l00141"></a>00141         kiss_y ^= kiss_y &lt;&lt; 5;
<a name="l00142"></a>00142         kiss_k = (kiss_z &gt;&gt; 2) + (kiss_w &gt;&gt; 3) + (kiss_carry &gt;&gt; 2);
<a name="l00143"></a>00143         kiss_m = kiss_w + kiss_w + kiss_z + kiss_carry;
<a name="l00144"></a>00144         kiss_z = kiss_w;
<a name="l00145"></a>00145         kiss_w = kiss_m;
<a name="l00146"></a>00146         kiss_carry = kiss_k &gt;&gt; 30;
<a name="l00147"></a>00147         <a class="code" href="classpopot_1_1rng_1_1KissRNG32.html#a3232b5bebefa0f1be4a9ac13dcf241fe">nb_calls</a> ++;
<a name="l00148"></a>00148         <span class="keywordflow">return</span> kiss_x + kiss_y + kiss_w;
<a name="l00149"></a>00149       }
<a name="l00150"></a>00150     };
<a name="l00151"></a>00151     <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> KissRNG32::kiss_x;
<a name="l00152"></a>00152     <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> KissRNG32::kiss_y;
<a name="l00153"></a>00153     <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> KissRNG32::kiss_z;
<a name="l00154"></a>00154     <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> KissRNG32::kiss_w;
<a name="l00155"></a>00155     <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> KissRNG32::kiss_carry;
<a name="l00156"></a>00156     <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> KissRNG32::kiss_k;
<a name="l00157"></a>00157     <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> KissRNG32::kiss_m;
<a name="l00158"></a>00158     <span class="keywordtype">int</span> KissRNG32::nb_calls;
<a name="l00159"></a>00159 
<a name="l00160"></a>00160 
<a name="l00164"></a>00164     <span class="keyword">class </span>CRNG
<a name="l00165"></a>00165     {     
<a name="l00166"></a>00166     <span class="keyword">public</span>:
<a name="l00167"></a>00167 <span class="preprocessor">#if defined(__GXX_EXPERIMENTAL_CXX0X__)</span>
<a name="l00168"></a>00168 <span class="preprocessor"></span>      <span class="keyword">static</span> constexpr <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="classpopot_1_1rng_1_1CRNG.html#ae7a65482946cf99bb45499141bc5ba6c">RNG_RAND_MAX</a> = RAND_MAX;
<a name="l00169"></a>00169 <span class="preprocessor">#else</span>
<a name="l00170"></a><a class="code" href="classpopot_1_1rng_1_1CRNG.html#ae7a65482946cf99bb45499141bc5ba6c">00170</a> <span class="preprocessor"></span>      <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="classpopot_1_1rng_1_1CRNG.html#ae7a65482946cf99bb45499141bc5ba6c">RNG_RAND_MAX</a> = RAND_MAX;
<a name="l00171"></a>00171 <span class="preprocessor">#endif</span>
<a name="l00172"></a><a class="code" href="classpopot_1_1rng_1_1CRNG.html#a80fb2aef72701dcb1f93db4ea588d012">00172</a> <span class="preprocessor"></span>      <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="classpopot_1_1rng_1_1CRNG.html#a80fb2aef72701dcb1f93db4ea588d012">nb_calls</a>;
<a name="l00173"></a>00173 
<a name="l00174"></a><a class="code" href="classpopot_1_1rng_1_1CRNG.html#a00fafa689c37af7516cd8c4d10395a82">00174</a>       <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classpopot_1_1rng_1_1CRNG.html#a00fafa689c37af7516cd8c4d10395a82">rng_srand</a>()
<a name="l00175"></a>00175       {
<a name="l00176"></a>00176         <span class="comment">// Random initialization of the seed</span>
<a name="l00177"></a>00177         <span class="comment">// To really get different seeds, ensure that the calls</span>
<a name="l00178"></a>00178         <span class="comment">// are separated by at least 1 s.</span>
<a name="l00179"></a>00179         <a class="code" href="classpopot_1_1rng_1_1CRNG.html#a00fafa689c37af7516cd8c4d10395a82">CRNG::rng_srand</a>(time(NULL));
<a name="l00180"></a>00180       }
<a name="l00181"></a>00181 
<a name="l00182"></a><a class="code" href="classpopot_1_1rng_1_1CRNG.html#ab81ea61fa00bfa148cb6aad974803c07">00182</a>       <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classpopot_1_1rng_1_1CRNG.html#a00fafa689c37af7516cd8c4d10395a82">rng_srand</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> seed)
<a name="l00183"></a>00183       {
<a name="l00184"></a>00184         srand(seed);
<a name="l00185"></a>00185         <a class="code" href="classpopot_1_1rng_1_1CRNG.html#a80fb2aef72701dcb1f93db4ea588d012">nb_calls</a> = 0;
<a name="l00186"></a>00186       }
<a name="l00187"></a>00187 
<a name="l00188"></a><a class="code" href="classpopot_1_1rng_1_1CRNG.html#a2c66f76b9a63287f90505393befdd587">00188</a>       <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classpopot_1_1rng_1_1CRNG.html#a2c66f76b9a63287f90505393befdd587">rng_warm_up</a>(<span class="keywordtype">void</span>)
<a name="l00189"></a>00189       {
<a name="l00190"></a>00190         <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i = 0 ; i &lt; 10000 ; ++i)
<a name="l00191"></a>00191           <a class="code" href="classpopot_1_1rng_1_1CRNG.html#a0d1e550ad3b7fbe63c767b0b1793c58e">rng_rand</a>();
<a name="l00192"></a>00192       }
<a name="l00193"></a>00193 
<a name="l00194"></a>00194       <span class="comment">// Generate a random number in [0 ; RAND_MAX [</span>
<a name="l00195"></a><a class="code" href="classpopot_1_1rng_1_1CRNG.html#a0d1e550ad3b7fbe63c767b0b1793c58e">00195</a>       <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="classpopot_1_1rng_1_1CRNG.html#a0d1e550ad3b7fbe63c767b0b1793c58e">rng_rand</a>(<span class="keywordtype">void</span>)
<a name="l00196"></a>00196       {
<a name="l00197"></a>00197         <a class="code" href="classpopot_1_1rng_1_1CRNG.html#a80fb2aef72701dcb1f93db4ea588d012">nb_calls</a>++;
<a name="l00198"></a>00198         <span class="keywordflow">return</span> rand();
<a name="l00199"></a>00199       }
<a name="l00200"></a>00200     };
<a name="l00201"></a>00201     <span class="keywordtype">int</span> CRNG::nb_calls;
<a name="l00202"></a>00202 
<a name="l00203"></a>00203   }
<a name="l00204"></a>00204 }
<a name="l00205"></a>00205 
<a name="l00206"></a>00206 <span class="preprocessor">#endif</span>
</pre></div></div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5
</small></address>

</body>
</html>
